package com.gitee.controller;

import com.gitee.adapter.Login3rdAdapter;
import com.gitee.pojo.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户登录  第三方登录 适配器模式  桥接模式
 *
 * @author acao
 * @since 2023-11-06 09:56
 */
@RestController
public class UserController {

    @Autowired
    private Login3rdAdapter login3rdAdapter;

    /**
     * 用户登录
     *
     * @param account  账号
     * @param password 密码
     */
    @PostMapping("login")
    public String login(String account, String password) {
        return login3rdAdapter.login(account, password);
    }

    /**
     * 用户注册
     *
     * @param userInfo userinfo
     */
    @PostMapping("register")
    public String register(@RequestBody UserInfo userInfo) {
        return login3rdAdapter.register(userInfo);
    }


    /**
     * 第三方登录回调地址
     */
    @GetMapping("giteeLogin")
    public String giteeLogin(String code) {
        return login3rdAdapter.giteeLogin(code);
    }

}
